package com.coolbi.security.dao.impl;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.security.dao.RoleToUserDao;
import com.coolbi.security.entity.RoleToUser;
import com.coolbi.security.entity.Roles;
import com.coolbi.security.entity.User;
import com.coolbi.security.mapper.RoleToUserMapper;

public class RoleToUserDaoImpl implements RoleToUserDao {

	@Autowired
	private RoleToUserMapper roleToUserMapper;

	public void setRoleToUserMapper(RoleToUserMapper roleToUserMapper) {
		this.roleToUserMapper = roleToUserMapper;
	}

	@Override
	public List<Roles> findRoleByUserId(long id) {
		return roleToUserMapper.findRoleByUserId(id);
	}

	@Override
	public List<User> findUserByRoleId(long id) {
		return roleToUserMapper.findUserByRoleId(id);
	}

	@Override
	public List<RoleToUser> find(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUser> find(Map<String, Object> parameter, int offset,
			int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<RoleToUser> search(String keyword, int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int countByKeyword(String keyword) {
		return 0;
	}

	@Override
	public RoleToUser save(RoleToUser obj) {
		roleToUserMapper.save(obj);
		return obj;
	}

	@Override
	public int update(RoleToUser obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(long id) {
		return roleToUserMapper.delete(id);
	}

	@Override
	public RoleToUser get(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUser> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUser> list(int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByRoleId(long id) {
		return roleToUserMapper.deleteByRoleId(id);
	}

	@Override
	public List<Roles> findGroupRoleByUserId(long id) {
		return roleToUserMapper.findGroupRoleByUserId(id);
	}

	@Override
	public List<Long> findByRolesAndUserId(Long[] roleArray, Long userId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("userId", userId);
		parameter.put("roleId", Arrays.asList(roleArray));
		return roleToUserMapper.findByRolesAndUserId(parameter);
	}

	@Override
	public int deleteByRoleIds(Long[] roleArray, Long userId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("userId", userId);
		parameter.put("roleId", Arrays.asList(roleArray));
		return roleToUserMapper.deleteByRoleIds(parameter);
	}
}
